﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Engine.Sgml.Allocation;
using Engine.Sgml.Matching;
using Engine.Sgml.Schema;
using Engine.Sgml.Merging;
using Engine.Sgml.Assembling;

namespace Engine.Sgml.Validation {
    internal sealed class ModelValidator {
        private ModelMatcher modelMatcher = new ModelMatcher();
        private MatchMerger matchMerger = new MatchMerger();

        public IList<InconsistentBlock> Validate(SElement node) {
            Guard.ArgumentNotNull(node, "node");
            if (!node.HasDeclaration)
                throw new InvalidOperationException("Could not validate the specified node. The node doesn't have DTD declaration.");
            IList<Capture> captures = modelMatcher.Match(node);
            return matchMerger.Merge(captures);
            }
        }
    }